import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mac
 * Date: 2022-08-18
 * Time: 12:11
 */
public class MethodWorkDemo {
    //1.找出出现一次的数字
    public static void main1(String[] args) {
        int[] array = {1, 2, 3, 2, 1};
        int sum = array[0];
        for (int i = 1; i < array.length; i++) {
            sum ^= array[i];
        }
        System.out.println(sum);
    }

    //2.斐波那契数列
    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int x = 1, y = 1, m = 0;
            if (n == 1 || n == 2) {
                m = 1;
            } else {
                n -= 2;
                while (n != 0){
                    m = x + y;
                    x = y;
                    y = m;
                    n--;
                }
            }
            System.out.println(m);
        }
    }

    //3 - 求1！+2！+3！+4！+........+n!的和
    public static  int fun(int n){
        int ret = 1;
        for (int i = 1; i <= n; i++) {
            ret *= i;
        }
        return ret;
    }
    public  static  int funSum(int n){
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += fun(i);
        }
        return sum;
    }
    public static void main3(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()){
            int n = scanner.nextInt();
            System.out.println(funSum(n));
        }
    }

    //4.奇数位于偶数之前
    public static void main4(String[] args) {
          int[] array = { 1,2,3,4,5 };
          int left = 0;
          int right = array.length - 1;
          while (left < right){
              while (left < right && array[left] % 2 != 0){
                  left++;
              }
              while (left < right && array[right] % 2 == 0){
                  right--;
              }
              int tmp = array[left];
              array[left] = array[right];
              array[right] = tmp;
          }
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
    }

    //求最大值
    public  static  int max2(int a, int b){
        return a > b ? a : b;
    }
    public static  int  max3(int a, int b ,int c){
        return max2(max2(a, b), c);
    }

    public static void main(String[] args) {
        System.out.println(max3(1,2,3));
    }
}
